+2006-03-03 Michael Natterer <mitch@imendio.com>
+
+ Applied modified patch from maemo-gtk which makes separators more
+ themeable. Fixes bug #332022.
+
+ * gtk/gtkwidget.c: added style properties "wide-separators",
+ "separator-width" and "separator-height".
+
+ * gtk/gtkhseparator.c
+ * gtk/gtkvseparator.c
+ * gtk/gtkmenuitem.c
+ * gtk/gtktoolbar.c: honor the new settings and paint separators
+ using gtk_paint_box() if wide-separators is true.
+
2006-03-02 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c: Fix combobox theming
+2006-03-03 Michael Natterer <mitch@imendio.com>
+
+ Applied modified patch from maemo-gtk which makes separators more
+ themeable. Fixes bug #332022.
+
+ * gtk/gtkwidget.c: added style properties "wide-separators",
+ "separator-width" and "separator-height".
+
+ * gtk/gtkhseparator.c
+ * gtk/gtkvseparator.c
+ * gtk/gtkmenuitem.c
+ * gtk/gtktoolbar.c: honor the new settings and paint separators
+ using gtk_paint_box() if wide-separators is true.
+
2006-03-02 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c: Fix combobox theming
#include "gtkalias.h"
-static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
-static void gtk_hseparator_init (GtkHSeparator *hseparator);
-static gint gtk_hseparator_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
+static void gtk_hseparator_init (GtkHSeparator *hseparator);
+static void gtk_hseparator_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static gint gtk_hseparator_expose (GtkWidget *widget,
+ GdkEventExpose *event);
GType
widget_class = (GtkWidgetClass*) class;
+ widget_class->size_request = gtk_hseparator_size_request;
widget_class->expose_event = gtk_hseparator_expose;
}
return g_object_new (GTK_TYPE_HSEPARATOR, NULL);
}
+static void
+gtk_hseparator_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ gboolean wide_separators;
+ gint separator_height;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ NULL);
+
+ if (wide_separators)
+ requisition->height = separator_height;
+ else
+ requisition->height = widget->style->ythickness;
+}
static gint
gtk_hseparator_expose (GtkWidget *widget,
GdkEventExpose *event)
{
if (GTK_WIDGET_DRAWABLE (widget))
- gtk_paint_hline (widget->style, widget->window, GTK_WIDGET_STATE (widget),
- &event->area, widget, "hseparator",
- widget->allocation.x,
- widget->allocation.x + widget->allocation.width - 1,
- widget->allocation.y + (widget->allocation.height -
- widget->style->ythickness) / 2);
+ {
+ gboolean wide_separators;
+ gint separator_height;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ NULL);
+
+ if (wide_separators)
+ gtk_paint_box (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+ &event->area, widget, "hseparator",
+ widget->allocation.x,
+ widget->allocation.y + (widget->allocation.height -
+ separator_height) / 2,
+ widget->allocation.width,
+ separator_height);
+ else
+ gtk_paint_hline (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget),
+ &event->area, widget, "hseparator",
+ widget->allocation.x,
+ widget->allocation.x + widget->allocation.width - 1,
+ widget->allocation.y + (widget->allocation.height -
+ widget->style->ythickness) / 2);
+ }
return FALSE;
}
requisition->width = MAX (requisition->width, get_minimum_width (widget));
}
}
- else
+ else /* separator item */
{
- /* separator item */
- requisition->height += 4;
+ gboolean wide_separators;
+ gint separator_height;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ NULL);
+
+ if (wide_separators)
+ requisition->height += separator_height + widget->style->ythickness;
+ else
+ requisition->height += widget->style->ythickness * 2;
}
accel_width = 0;
}
else if (!GTK_BIN (menu_item)->child)
{
- guint horizontal_padding;
+ gboolean wide_separators;
+ gint separator_height;
+ guint horizontal_padding;
gtk_widget_style_get (widget,
- "horizontal-padding", &horizontal_padding,
- NULL);
-
- gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
- area, widget, "menuitem",
- widget->allocation.x + horizontal_padding + widget->style->xthickness,
- widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
- widget->allocation.y + (widget->allocation.height -
- widget->style->ythickness) / 2);
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ "horizontal-padding", &horizontal_padding,
+ NULL);
+
+ if (wide_separators)
+ gtk_paint_box (widget->style, widget->window,
+ GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
+ area, widget, "hseparator",
+ widget->allocation.x + horizontal_padding + widget->style->xthickness,
+ widget->allocation.y + (widget->allocation.height -
+ separator_height -
+ widget->style->ythickness) / 2,
+ widget->allocation.width -
+ 2 * (horizontal_padding + widget->style->xthickness),
+ separator_height);
+ else
+ gtk_paint_hline (widget->style, widget->window,
+ GTK_STATE_NORMAL, area, widget, "menuitem",
+ widget->allocation.x + horizontal_padding + widget->style->xthickness,
+ widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
+ widget->allocation.y + (widget->allocation.height -
+ widget->style->ythickness) / 2);
}
}
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_paint_vline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "toolbar",
- allocation->y + allocation->height * start_fraction,
- allocation->y + allocation->height * end_fraction,
- allocation->x + (allocation->width - widget->style->xthickness) / 2);
+ gboolean wide_separators;
+ gint separator_width;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-width", &separator_width,
+ NULL);
+
+ if (wide_separators)
+ gtk_paint_box (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+ area, widget, "vseparator",
+ allocation->x + (allocation->width - separator_width) / 2,
+ allocation->y + allocation->height * start_fraction,
+ separator_width,
+ allocation->height * (end_fraction - start_fraction));
+ else
+ gtk_paint_vline (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), area, widget,
+ "toolbar",
+ allocation->y + allocation->height * start_fraction,
+ allocation->y + allocation->height * end_fraction,
+ allocation->x + (allocation->width - widget->style->xthickness) / 2);
}
else
{
- gtk_paint_hline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "toolbar",
- allocation->x + allocation->width * start_fraction,
- allocation->x + allocation->width * end_fraction,
- allocation->y + (allocation->height - widget->style->ythickness) / 2);
+ gboolean wide_separators;
+ gint separator_height;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ NULL);
+
+ if (wide_separators)
+ gtk_paint_box (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+ area, widget, "hseparator",
+ allocation->x + allocation->width * start_fraction,
+ allocation->y + (allocation->height - separator_height) / 2,
+ allocation->width * (end_fraction - start_fraction),
+ separator_height);
+ else
+ gtk_paint_hline (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), area, widget,
+ "toolbar",
+ allocation->x + allocation->width * start_fraction,
+ allocation->x + allocation->width * end_fraction,
+ allocation->y + (allocation->height - widget->style->ythickness) / 2);
}
}
#include "gtkalias.h"
-static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
-static void gtk_vseparator_init (GtkVSeparator *vseparator);
-static gint gtk_vseparator_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
+static void gtk_vseparator_init (GtkVSeparator *vseparator);
+static void gtk_vseparator_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static gint gtk_vseparator_expose (GtkWidget *widget,
+ GdkEventExpose *event);
GType
widget_class = (GtkWidgetClass*) klass;
+ widget_class->size_request = gtk_vseparator_size_request;
widget_class->expose_event = gtk_vseparator_expose;
}
return g_object_new (GTK_TYPE_VSEPARATOR, NULL);
}
+static void
+gtk_vseparator_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ gboolean wide_separators;
+ gint separator_width;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-width", &separator_width,
+ NULL);
+
+ if (wide_separators)
+ requisition->height = separator_width;
+ else
+ requisition->height = widget->style->xthickness;
+}
static gint
gtk_vseparator_expose (GtkWidget *widget,
GdkEventExpose *event)
{
if (GTK_WIDGET_DRAWABLE (widget))
- gtk_paint_vline (widget->style, widget->window, GTK_WIDGET_STATE (widget),
- &event->area, widget, "vseparator",
- widget->allocation.y,
- widget->allocation.y + widget->allocation.height - 1,
- widget->allocation.x + (widget->allocation.width -
- widget->style->xthickness) / 2);
+ {
+ gboolean wide_separators;
+ gint separator_width;
+
+ gtk_widget_style_get (widget,
+ "wide-separators", &wide_separators,
+ "separator-width", &separator_width,
+ NULL);
+
+ if (wide_separators)
+ gtk_paint_box (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+ &event->area, widget, "vseparator",
+ widget->allocation.x + (widget->allocation.width -
+ separator_width) / 2,
+ widget->allocation.y,
+ separator_width,
+ widget->allocation.height);
+ else
+ gtk_paint_vline (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget),
+ &event->area, widget, "vseparator",
+ widget->allocation.y,
+ widget->allocation.y + widget->allocation.height - 1,
+ widget->allocation.x + (widget->allocation.width -
+ widget->style->xthickness) / 2);
+ }
return FALSE;
}
P_("Visited Link Color"),
P_("Color of visited links"),
GDK_TYPE_COLOR,
- GTK_PARAM_READABLE));
+ GTK_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boolean ("wide-separators",
+ P_("Wide Separators"),
+ P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
+ FALSE,
+ GTK_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("separator-width",
+ P_("Separator Width"),
+ P_("The width of separators if wide-separators is TRUE"),
+ 0, 64, 0,
+ GTK_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("separator-height",
+ P_("Separator Height"),
+ P_("The height of separators if wide-separators is TRUE"),
+ 0, 64, 0,
+ GTK_PARAM_READABLE));
}
static void